package com.exam.online.system.dao;

import com.exam.online.system.entity.StuPaper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StuPaperDAO {
    int deleteByPrimaryKey(Integer id);

    int insert(StuPaper record);

    int insertSelective(StuPaper record);

    StuPaper selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(StuPaper record);

    int updateByPrimaryKey(StuPaper record);

    @Select("select * from `t_stu_paper` where paper_id = #{paperId} and stu_id = #{userId}")
    StuPaper selectByPaperIdAndStuId(@Param("paperId") Integer paperId, @Param("userId") Integer userId);

    @Select("select * from `t_stu_paper` where stu_id = #{stuId} and is_exam = #{isExam} limit #{pageNo},#{pageSize}")
    List<StuPaper> listUnExamPaper(@Param("stuId") Integer stuId, @Param("isExam") Integer isExam, @Param("pageNo") int pageNo, @Param("pageSize") Integer pageSize);

    @Select("select count(*) from `t_stu_paper` where stu_id = #{stuId} and is_exam = #{isExam}")
    int totalByStuIdAndIsExam(@Param("stuId") Integer stuId, @Param("isExam") Integer isExam);

    @Select("select * from `t_stu_paper` where paper_id = #{paperId}")
    List<StuPaper> selectByPaperId(@Param("paperId") Integer paperId);

}